package demo.util_ui.client.ui;

import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class UIFactory {

	public static FlowPanel createFlowPanel(final Widget... contents) {
		FlowPanel result = new FlowPanel();

		for (Widget w : contents) {
			result.add(w);
		}
		return result;
	}

	public static HorizontalPanel createHorizontalPanel(
			final Widget... contents) {
		HorizontalPanel result = new HorizontalPanel();

		for (Widget w : contents) {
			result.add(w);
		}
		return result;
	}

	public static Label createLabel(final String text, final String style) {
		Label result = new Label(text);
		result.addStyleName(style);
		return result;
	}

	public static SimplePanel createSimplePanel(final Widget content) {
		return createSimplePanel(content, null);
	}

	public static SimplePanel createSimplePanel(final Widget content,
			final String styleName) {
		SimplePanel result = new SimplePanel();

		result.add(content);
		if (null != styleName) {
			result.addStyleName(styleName);
		}

		return result;
	}

	public static VerticalPanel createVerticalPanel(final Widget... contents) {
		VerticalPanel result = new VerticalPanel();

		for (Widget w : contents) {
			result.add(w);
		}
		return result;
	}

}
